/*================================ 防止框架被截断  ==============================*/
fusion2.canvas.setHeight({height:$("body").height()});
/*================================ begin 统计  ==============================*/
function statistics(_type){
	$.ajax({
		type: "GET",
		url: $(".page_url").val()+"?c=common2&m=AjaxStatistics",
		data: "type="+encodeURIComponent(_type)+"&",
		dataType: "json",
		success: function(rs){
			fusion2.ui.hideMsgbox();
		}
	});
}
/*================================ end 统计  ==============================*/
/*================================ begin 分享收藏、提醒  ==============================*/
//分享接口的两个参数值
function shareInfo() {
		var array1 = new Array('好赞的东东~真心不错！白菜价呀！我Hold不住了~~~~~', '好喜欢肿么办！而且性价比超高的~！分享给大家瞧瞧~很赞，有木有？！！', '被这款秒杀了，好心水~(*^__^*) ~JMS一起来看看吧~', '被这款秒杀了，好心水~(*^__^*) ~JMS一起来看看吧~');
		var array2 = new Array("每天精选十个超值热卖宝贝~【优品购物】~至IN潮人必备！点击安装>>>", "优品购物，只选优品！让你从头赞到尾~点击查看更多宝贝>>>", "款式美，颜色俏，性价比超高！购物达人明智之选~点击安装【优品购物】>>>", "汇聚全网至IN超值单品，变身潮人就是这么简单~点击安装>>>");
		var array3 = new Array("大爱超值宝贝，明智购物之选~你值得拥有！", "点击链接，添加应用，精选超值优品每日推送~", "精选超高性价比单品，每天享不停~O(∩_∩)O~", "达人推荐太给力了！点击链接，添加应用你也是达人哦");
		var rand1 = Math.floor(Math.random() * 4);
		var rand2 = Math.floor(Math.random() * 4);
		var rand3 = Math.floor(Math.random() * 4);
		return [array1[rand1], array2[rand2], array3[rand3]];
}
//分享接口
var __HAS_SHARED = 0;
function apishare(_rs, _pics, _id, _isaddgold) {
	/* _rs是个数组0:msg,1:summary,2:title
	 * _isaddgold值， 1:需要加金币2:改变全局变量
	 */
	if (1==2) {//微博 pf == "tapp"
		//暂时为空
	}else {//朋友空间平台
		fusion2.dialog.sendStory({
			img: _pics,
			msg: _rs[0],
			summary: _rs[1],
			title: _rs[2],
			onSuccess: function() {
				if(_isaddgold && _isaddgold!=2) AjaxSharedAddGold();
				if(_isaddgold && _isaddgold==2 && _USER_AWARD_STEP==1) {
					f_show_zhuanpan();//这个在转盘js里
					__HAS_SHARED=1;
				}
			},
			onClose: function() {},
			onCancel: function() {}
		});
	}
}
//接口分享加金币
function AjaxSharedAddGold(){
	var __gold_num = $(".gold_corn #gold");
	$.ajax({
		type: "GET",
		url: $(".page_url").val()+"?c=common2&"+"m=AjaxSharedAddGold&",
		dataType: "json",
		success: function(rs){
			if(rs.ret<0){
				fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 2000});
				return false;
			}
			//领取成功
			if(rs.ret==1) {
				if(rs.addGold>0){
					__gold_num.text(rs.totalGold);//用户金币数
					fusion2.ui.showMsgbox({type: 2,msg: "分享成功，您已获得"+rs.addGold+"金币奖励。",timeout: 2000});
				}else{
					fusion2.ui.showMsgbox({type: 2,msg: "您今天已经分享过，请明天再来哦~",timeout: 2500});
				}
			}
		}
	});
	return false;
}
//分享组件
function zoneshare(_rs, _pics, _id){
		//_rs是个数组0:desc,1:summary,2:title
		var _locat='http://rc.qzone.qq.com/100656353?via=DLJ&source=1_'+_id+'&';
		var url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(_locat)+'&title='+encodeURIComponent(_rs[2])+'&pics='+encodeURIComponent(_pics)+'&summary='+encodeURIComponent(_rs[1])+'&desc='+encodeURIComponent(_rs[0]);
		var dialog = new fusion.LIB.Dialog({
			title: "分享",
			size: {
				w: 610,
				h: 600
			},
			src: url,
			onClose: function() {},
			onSuccess: function() {}
		});
}
//qq提醒功能
function __QQ_REMINDER(_time,_title,_content) {
	//时间
	var d = new Date();
	d.setDate(d.getDate()+1);
	var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
	_time = _time?_time:(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" 10:00");
	//标题
	_title = _title?_title:"优品购物兑换提醒";
	//内容
	_content=_content?_content:"金币可以直接兑换商品啦，每天10点准时开抢,赶紧来兑换吧！";
	var __qqClockShare = {
			title: _title,
			content: encodeURIComponent(_content),
			time: encodeURIComponent(_time),
			url: encodeURIComponent("http://rc.qzone.qq.com/100656353?rand="+Math.random())
	};

	fusion2.ui.showDialog({
		title: __qqClockShare.title,
		src: 'http://qzs.qq.com/snsapp/app/bee/widget/open.htm#content=' + __qqClockShare.content + 
				'&time=' + __qqClockShare.time + '&advance=5&url=' + __qqClockShare.url,
		size: { w: 600, h: 472 }
	});
	return false;
}
/*================================ end 分享收藏、提醒 ==============================*/
/*================================ begin 弹框 code ==============================*/
function maskHeight(){
	var mask = document.getElementById("mask");
	var iframe = mask.getElementsByTagName("iframe")[0];
	var winHeight = document.documentElement.clientHeight || document.body.clientHeight;
	var maxHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
	if(winHeight < maxHeight){
		winHeight = maxHeight;	
	}
	iframe.style.height = mask.style.height = winHeight + "px";
}
$(".close,.box_close2,.close100").live("click",function(){//close2无css
	if($("#mask").css("display")=="block"){
		$("#mask").hide();
	}
	$(this).parents(".module").hide();
});
function openpop(){
	//遮罩层
	maskHeight();
	$("#mask").show();
	$("#pop").show();
	//更改位置
	fusion2.canvas.getClientRect({	
		onSuccess: function (rect) {
			var top1 = rect.top;
			var bottom1 = top1?rect.bottom:"700";
			var left1 = rect.left;
			var right1 = rect.right;
			$("#pop").css("top", parseInt(top1)+(parseInt(bottom1)-parseInt(top1)-parseInt($("#pop-content").children("div").css("height")))/2);
			$("#pop").css("left",parseInt(left1) + (parseInt(right1)-parseInt(left1) - parseInt( $("#pop-content").children("div").css("width") )) /2);
		}
	});
}

/*================================ end 弹框 code ================================*/


$(document).ready(function(){
	//ajax
	$(".AJAX-LOADING").ajaxStart(function(){
		fusion2.ui.showMsgbox({type: 4,msg: "正在处理，请稍候，(∵)nnn"});
	});
	/*$(".AJAX-LOADING").ajaxComplete(function(){
		fusion2.ui.hideMsgbox();
	});*/
	//页面地址
	var __SITEURL = $(".page_url").val();
	var __PAGEURL = $(".page_url").val()+"?c=common2&";
	//“动态调整页面展现”前端JS接口
	fusion2.iface.updateClientRect(function (rect)  { 
		var top1 = rect.top;
		var bottom1 = rect.bottom;
		$("#pop").css("top", parseInt(top1)+(parseInt(bottom1)-parseInt(top1)-parseInt($("#pop-content").children("div").css("height")))/2);
	});
	/*================================ xxxxx任务xxxxx ==============================*/
	/* ---------------------------弹出任务-------------------------- */
	$(".task").live("click",function(){
		var __gold_num = $(".gold_corn #gold");
		var __txData = jQuery.parseJSON($(".txData").val());//一些参数
		var __renwu_html = '<div class="gold-change-box">'+
			'<p class="gold title">做任务赚金币</p>'+
			'<a href="javascript:void(0);" class="close"><img src="appearance/goldchange_box/close.png" alt="close" /></a>'+
			'<ul class="time-machines clearfix">'+
				'<li style="margin-left:5px;"> <a href="javascript:void(0)" id="renwu-qiandao"><img alt="每日签到" src="appearance/goldchange_box/icon_signin.jpg" class="picture"><div class="work"><p>每日签到</p><p>获得100+金币</p></div></a></li>'+
				'<li>'+
					'<a id="renwu-guanzhu" href="javascript:void(0)"><img alt="关注空间" src="appearance/goldchange_box/icon_follow.jpg" class="picture"><div class="work"><p>关注空间</p><p>获得500金币</p></div></a>';
		if(__txData.fanQQ.is_fan==0){
			__renwu_html +='<div class="ifram-guanzhu"><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe><iframe src="http://open.qzone.qq.com/like?url=http%3A%2F%2Fuser.qzone.qq.com%2F'+__txData.fanQQ.fan_qq+'&type=button&width=400&height=30&style=2" allowtransparency="true" scrolling="no" border="0" frameborder="0"></iframe></div>';

		}
			__renwu_html +='</li>'+
				'<li><a href="javascript:void(0)" id="renwu-QQMianBan"><img alt="添加到QQ面板" src="appearance/goldchange_box/icon_addqq.jpg" class="picture"><div class="work"><p>添加到QQ面板</p><p>获得500金币</p></div></a></li>'+
				'<li style="margin-right:0px;"><a href="javascript:void(0)" id="renwu-appShare"> <img alt="分享应用" src="appearance/goldchange_box/icon_share.jpg" class="picture"><div class="work"><p>分享应用</p><p>获得100金币</p></div></a></li>'+
				'<li><a href="javascript:void(0)" id="renwu-yaoqing"><img alt="邀请新朋友成功" src="appearance/goldchange_box/icon_invite.jpg" class="picture"><div class="work"><p>邀请新朋友成功</p><p>获得100金币</p></div></a></li>'+
				'<li><a href="javascript:void(0)" id="renwu-zhaohuan"><img alt="召唤老朋友成功" src="appearance/goldchange_box/icon_oldfriends.jpg" class="picture"><div class="work"><p>召唤老朋友成功</p><p>获得100金币</p></div></a></li>'+
			'</ul>'+
			'<p class="exchange title">金币兑换奖励<a href="'+__SITEURL+'?c=auction" class="lookmore">查看更多兑换奖品>></a></p>'+
			'<ul class="exchange-machines clearfix">'+
			'</ul>'+
			'</div>';
		$("#pop-content").html(__renwu_html);
		openpop();
		/* ---------------------------任务中兑换的奖品-------------------------- */
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxTaskExchangeGoods&",
			data: "",
			dataType: "json",
			success: function(rs){
				fusion2.ui.hideMsgbox();
				if(rs.ret==1){//有兑换的商品
					var _html = '';
					var _exchange_ul = $(".gold-change-box .exchange-machines");
					$.each( rs.goods, function(i, n){
						_html += '<li><a href="'+__SITEURL+'?c=auction"><img alt="兑换" src="'+n.pic+'" title="'+n.name+'"/><p>立即兑换>></p></a></li>';
					});
					_exchange_ul.html(_html);
				}
			}
		});
		//关注组件加载
		/* ---------------------------2.2关注任务-------------------------- */
		if(__txData.fanQQ.is_fan==0){//如果还没关注
			var __time = 0;
			$('.ifram-guanzhu iframe').load(function() {
				__time++;
				if(__time>10){//点击关注按钮
					$.ajax({
						type: "GET",
						url: __PAGEURL+"m=AjaxGuanZhu&",
						data: "fanQQ="+__txData.fanQQ.fan_qq,
						dataType: "json",
						success: function(rs){
							if(rs.ret<0){
								fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 2000});
								return false;
							}
							if(rs.rs){
								$(".txData").val(rs.txData);//更改tx数据
								if(rs.rs.ret==1){//有得到金币
									__gold_num.text(rs.rs.totalGold);//用户金币数
									fusion2.ui.showMsgbox({type: 2,msg: "关注成功，您已获得"+rs.rs.addGold+"金币奖励。",timeout: 2000});
								}else{
									fusion2.ui.showMsgbox({type: 2,msg: "关注成功",timeout: 1000});
								}
							}else{
								fusion2.ui.showMsgbox({type: 3,msg: "请先关注！⊙﹏⊙",timeout: 1000});
							}
							//判断是否要删除关注组件
							var __txData2 = jQuery.parseJSON(rs.txData);//一些参数 new
							if(__txData2.fanQQ.is_fan==1) $(".gold-change-box .ifram-guanzhu").remove();
							
						}
					});
					
				}
			});
		}
	});
	/* ---------------------------1.签到任务-------------------------- */
	$("#renwu-qiandao").live("click",function(){
		var __gold_num = $(".gold_corn #gold");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxQianDao&",
			dataType: "json",
			success: function(rs){
				if(rs.ret<0){
					fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 2000});
					return false;
				}
				//领取成功
				if(rs.ret==1) {
					__gold_num.text(rs.totalGold);//用户金币数
					fusion2.ui.showMsgbox({type: 2,msg: "签到成功，您已获得"+rs.addGold+"金币奖励。",timeout: 3000});
				}else{
					fusion2.ui.showMsgbox({type: 1,msg: "您今天已签到过，记得明天再来哦~ ",timeout: 3000});
				}
			}
		});
	});
	/* ---------------------------2.1.关注任务-------------------------- */
	$("#renwu-guanzhu").live("click",function(){
		var __txData = jQuery.parseJSON($(".txData").val());//一些参数
		if(__txData.fanQQ.is_fan==1) fusion2.ui.showMsgbox({type: 1,msg: "您已经完成关注，请选择其他任务哦~",timeout: 2000});
	});
	/* ---------------------------3.添加到面板-------------------------- */
	$("#renwu-QQMianBan").live("click",function(){
		var __txData = jQuery.parseJSON($(".txData").val());//一些参数
		//是否已经添加到面板
		if(__txData.isAppOnPanel==1) {
			getAddClientPanelGold();
		}else{
			fusion2.dialog.addClientPanel({
				context : "add_Client_Panel",//随便设的
				onClose : function (opt) {getAddClientPanelGold();}
			});
		}
	});
	//添加到面板的金币操作
	function getAddClientPanelGold(){
		var __gold_num = $(".gold_corn #gold");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxAddPanelGold&",
			dataType: "json",
			cache: false,
			success: function(rs){
				if(rs.ret<0){
					fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 2000});
					return false;
				}
				fusion2.ui.hideMsgbox();
				$(".txData").val(rs.txData);//更改tx数据
				if(rs.ret){//添加成功
					if(rs.addGold>0) {//第一次添加
						__gold_num.text(rs.totalGold);//用户金币数
						fusion2.ui.showMsgbox({type: 1,msg: "添加到QQ面板成功，您已获得"+rs.addGold+"金币奖励。",timeout: 2000});
					}else{//已经领取过金币
						fusion2.ui.showMsgbox({type: 1,msg: "您已完成该任务，请选择其他任务哦~",timeout: 2000});
					}
				}else{
					fusion2.ui.showMsgbox({type: 3,msg: "请先添加到面板！⊙﹏⊙",timeout: 2000});
				}
			}
		});
		return false;
	}
	/* ---------------------------4.分享应用-------------------------- */
	$("#renwu-appShare").live("click",function(){
		var _pic = "http://ctc.qzonestyle.gtimg.cn/qzonestyle/act/qzone_app_img/app100656353_100656353_100.png";
		var _shareinfo = shareInfo();
		_shareinfo[2] = "我在玩这个好玩的哦~~~"; 
		apishare(_shareinfo, _pic, 0, 1);
	});
	/* ---------------------------5.邀请好友 renwu-yaoqing-------------------------- */
	$("#renwu-yaoqing").live("click",function(){
		fusion2.dialog.invite({
			msg  : "一起来玩吧~~~",
			img : "http://app100656353.qzone.qzoneapp.com/icon.png",
			source : "yaoqingrenwu",
			context : "invite",
			onSuccess : function (opt) {AjaxYaoqingORZhaohuan("yaoqing","yaoqing");},
			onCancel : function (opt) {}
			//onClose : function (opt) {AjaxGetYaoqingGold();}
		});
	});
	function AjaxYaoqingORZhaohuan(_action,_type){
		var __gold_num = $(".gold_corn #gold");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxYaoqingORZhaohuan&",
			data: "action="+_action,
			dataType: "json",
			success: function(rs){
				if(rs.ret<0){
					fusion2.ui.showMsgbox({type: 3,msg: rs.msg,timeout: 2000});
					return false;
				}
				//领取成功
				if(rs.ret==1) {
					if(rs.addGold>0){
						var _word = (_type=="yaoqing")?"邀请新朋友成功，您已获得"+rs.addGold+"金币奖励。":"召唤老朋友成功，您已获得"+rs.addGold+"金币奖励。";
						__gold_num.text(rs.totalGold);//用户金币数
						fusion2.ui.showMsgbox({type: 2,msg: _word,timeout: 2000});
					}else{
						fusion2.ui.showMsgbox({type: 1,msg: "每天可领取3次金币!",timeout: 1500});
					}
				}else{
					fusion2.ui.showMsgbox({type: 3,msg: "请重新操作!",timeout: 1500});
				}
			}
		});
	}
	/* ---------------------------6.召唤好友 renwu-zhaohuan-------------------------- */
	$("#renwu-zhaohuan").live("click",function(){
		fusion2.dialog.reactive({
			title : "赶快来，我要100金币~~~", 
			receiveImg: "http://app100656353.qzone.qzoneapp.com/icon.png",
			sendImg: "http://app100656353.qzone.qzoneapp.com/icon.png",
			//msg: "赶快回来和我一起玩这个应用吧，没有你很孤单啊。", 
			msg: "赶快来，我要100金币~~~", 
		    context : "", 
		    onSuccess : function (opt) {AjaxYaoqingORZhaohuan("zhaohuan","zhaohuan");},
		    onCancel : function (opt) { }
		    //onClose : function (opt) {AjaxYaoqingORZhaohuan("zhaohuan");}
		 });
	});
	/*================================ 用户收藏 ==============================*/
	//收藏内容
	$(".you_collect").click(function(){	
		$.ajax({
		   type: "GET",
		   url: __PAGEURL+"m=AjaxUserCollected&",
		   dataType: "json",
		   cache: false,
		   success: function(rs){
			   fusion2.ui.hideMsgbox();
			   var __is_lt_5_col = (parseInt(rs.ret)>5)?" pro_more":""; //超过5条数据，显示下拉框
			   var __collect_group_html = '<div class="user_collect"><h4>我的收藏</h4><a href="javascript:void(0)" class="close">关闭</a><div class="collect_group'+__is_lt_5_col+'">';//填充的html头部
			   if(rs.ret>0){
				   $.each( rs.data, function(i, n){
					   __collect_group_html+='<div class="collect_list clearfix">'+
						   '<a href="javascript:void()" class="pro_img" onclick="fusion2.nav.open({url:\''+n.goodsUrl+'&\'}); return false;">'+
					   	   '<img alt="" src="'+n.picture+'" onerror="this.src='+n.picture+'">'+
					   	   '</a><a href="javascript:void()" class="pro_tit" onclick="fusion2.nav.open({url:\''+n.goodsUrl+'&\'}); return false;">'+n.title+'</a>'+
					   	   '<span class="pro_price">￥'+n.currentPrice+'</span><a href="javascript:void(0)" class="remove" data-id="'+n.id+'">移除</a>'+
					   	   '<a href="javascript:void(0)" class="go_see" onclick="fusion2.nav.open({url:\''+n.goodsUrl+'&\'}); return false;">去看看&gt;&gt;</a>'+
					   	   '</div>';
				   });
			   }else{
				   __collect_group_html += '<p class="collect_tips">您当前的收藏夹为空。</p>';
			   }
			   __collect_group_html += '</div></div>';//填充的html尾部
			    $("#pop-content").html(__collect_group_html);
				openpop();
				
		   }
		});
		return false;
	});
	//移除收藏 user_collect remove
	$(".user_collect .remove").live("click",function(){
		var __this =$(this);
		var __id = __this.data("id");
		var __col_num = $(".col_num");
		$.ajax({
			type: "GET",
			url: __PAGEURL+"m=AjaxUserCollectedDel&",
			data: "id=" + __id,
			dataType: "json",
			success: function(rs) {
				fusion2.ui.hideMsgbox();
				//移除成功
				if(rs.ret>0){
					__col_num.text(parseInt(__col_num.text()) - 1);//收藏数 -1
					__this.parents(".collect_list").remove();//  删除list
					fusion2.ui.showMsgbox({
						type: 2,
						msg: "移除成功！",
						timeout: 2000
					});
					
				}
				//无收藏
				if( parseInt(__col_num.text())==0 ){
					$(".collect_group").html('<p class="collect_tips">您当前的收藏夹为空。</p>');
				}
				
			}
		});
		
	});
	/*================================ 倒计时 ==============================*/
	/*-----------------begin   在页面显示倒计时---------------*/
 	function addNum(num) {
		if (num < 10) {
			num = "0" + num;
		}
		return num;
	}
	(function ($) {
		$.fn.countdown = function (options) {
			var defaults =
			{
				timeRemaining: 0,
				callback: null
			};

			var options = $.extend(defaults, options);

			this.each(function () {
				var me = $(this);
				jmain();

				function jmain() {
					if (options.timeRemaining >= 0) {
						me.text(cdToString(options.timeRemaining));
						options.timeRemaining--;
						setTimeout(jmain, 1000);
					}
					else {
						if (isFunction(options.callback)) {
							options.callback();
						}
					}
				}
				function cdToString(s) {
					var t=	Math.floor(s/(3600*24)),
						h = addNum(Math.floor((s/3600)%24)),
						m = addNum(Math.floor((s % 3600) / 60)),
						s = addNum(Math.floor(s % 60)),
						mill = 9;
					if($('.cz-timedown').is(":visible")){
						
						clearInterval(this.millTimeout);
						
						me.find(".hour").html(h);
						me.find(".minute").html(m);

						this.millTimeout = setInterval(function(){
							me.find(".second").html(s+'.'+mill);
							if(mill > 0){
								mill--;
							}
						},99);
						
					}else if($('.askmore_time').is(":visible") || $('.askmore_time3').is(":visible")){
						me.html("<span>"+h+"</span><span>"+m+"</span><span>"+s+"</span>");
						
					}else if($("#todayAuction").is(":visible")){
						if(t=="0"){
							me.html("剩余时间："+h+"时"+m+"分"+s+"秒");
						}else{
							me.html("剩余时间："+t+"天"+h+"时"+m+"分"+s+"秒");
						}
					}else if($(".exchange-state-time h3").is(":visible")){
							me.html("距开抢还有："+h+"小时"+m+"分"+s+"秒");
					}else{
						me.html('<i></i><span>'+h+'</span>时<span>'+m+'</span>分<span>'+s+'</span>秒');	
					}	

				}
				function isFunction(fn) {
					return !!fn && !fn.nodeName &&
						fn.constructor != String &&
						fn.constructor != RegExp &&
						fn.constructor != Array &&
						/function/i.test(fn + "");
				}
			});
		};
	})(jQuery);
		 /* 首页竞拍倒计时 */
		var timeNow=$("#time_now").val();
		var timeEnd=$("#time_end").val();
		var timeEnd2=$("#time_ten_clock").val();
		var timeEnd11=new Date("2013/11/13 00:00:00").getTime()/1000;
		$(".askmore_time_nr").countdown({timeRemaining:timeEnd-timeNow,callback:function(){
			$(".askmore_time_nr").html("<span>00</span><span>00</span><span>00</span>");
		}});
		/* 9.9包邮倒计时 */
		for (var i = 0; i < $('.youtime').length; i++) {
			var starttime = parseInt($(".picture_list").data("startime"));
			var endtime = parseInt($(".picture_list").data("endtime"));
			if(starttime > endtime){
				$(".youtime").eq(i).html("<i></i>还未开始");
			}else{
				$(".youtime").eq(i).countdown({timeRemaining:endtime-timeNow,callback:function(){																													  				$(".youtime").eq(i).html("<i></i>已经结束");																									   
				}})	
			}
		}
		/* 今日竞拍剩余时间 */
		$("#todayAuction span").countdown({timeRemaining:timeEnd-timeNow,callback:function(){	
			$("#todayAuction span").html("剩余时间：00时00秒00分");																		   
		}});
		
		/* 推荐过来显示特殊商品倒计时 */
		$("#J_timeDown").countdown({
			timeRemaining:timeEnd-timeNow,
			callback:function(){	
				//alert("1");
			}
		})
	/*-----------------end   在页面显示倒计时---------------*/
	/*================================ 统计 ==============================*/
	/*-----------------begin 发现更多统计---------------*/
	$(".more_buy .more_lists a").click(function(){
		statistics("发现更多宝贝-9.9");
	});
	$(".more_buy .more_lists2 a").click(function(){
		statistics("发现更多宝贝-精选");
	});
	/*$(".tab-99").click(function(){
		statistics("tab-9.9");
	});*/
	/*$(".tab-jinbi").click(function(){
		statistics("tab-金币兑奖");
	});*/
	$(".interactive .li-task").click(function(){
		statistics("头部-任务");
	});
	$(".interactive .li-jinbiduijiang").click(function(){
		statistics("头部-金币兑奖");
	});
	/*----------------- end  发现更多统计---------------*/
});
